# 1. 用类封装一个MyMath类, 实现加, 减, 乘, 除, 幂, 开方

class MyMath:
    def add(self, x, y):
        return x + y
    # 1、加法
    def suy(self, x, y):
        return x - y
    # 2、减法
    def mul(self, x, y):
        return x * y
    # 3、乘法
    def divide(self, x, y):
        return x / y
    # 4、除法
    def douyle_div(self, x, y):
        return x // y
    # 5、整除
    def surplus(self, x, y):
        return x ** y
    # 6、幂
    def sqrt(self, x):
        return x ** (1 / 2)
    # 7、开方

print("1：加法")
print("2：减法")
print("3：乘法")
print("4：除法")
print("5：整除")
print("6：幂")
print("7：开方")

A = input("请输入数字,选择你想进行的运算: ")

if A == '7':
    x = int(input("请输入数字进行开方:"))
else:
    x = int(input("请输入第 1 个数字:"))
    y = int(input("请输入第 2 个数字:"))

c = MyMath()
if A == '1':
    print(x, "+",y ,"=" , c.add(x, y))
elif A == "2":
    print(x, "-", y,"=", c.suy(x,y))
elif A == "3":
    print(x, "*", y,"=", c.mul(x,y))
elif A == "4":
    print(x, "/", y,"=", c.devide(x,y))
elif A == "5":
    print(x, "//", y,"=", c.douyle_div(x,y))
elif A == "6":
    print(x, "**", y,"=", c.surplus(x,y))
elif A == "7":
    print(x, "开方的结果为:","=",c.sqrt(x))
else:
    print("请在指定范围内进行选择！")

# 2,3. 由课题, 大家按自己的想法, 将身边的事物抽象出一个类, 并创建多个实例
class Cars:
    a = "丰田"
    b = "宝马"
    c = "奔驰"
    d = "福特"
    e = "长安"
    def __init__(self, a1, b1, c1, d1, e1):
        self.a = a1
        self.b = b1
        self.c = c1
        self.d = d1
        self.e = e1

class Car(Cars):
    print(Cars.b)

class Mycar(Car):
    print("我的车是:",Cars.a)

# 尝试
class Cars:
    x = "小明"
    y = "奥迪"
    def __init__(self, a, b):
        self.x = a
        self.y = b
    def BuyCar(self):
        print("%s想买的车是: %s" % (self.x, self.y))

class Car(Cars):
    print(Cars.y)

class Mycar(Cars):
    print(Cars.x,"的车是:",Cars.y)

p = Cars("弟弟", "奔驰550")
p.BuyCar()